package com.grf.hadoop.practice;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class HttpBean implements WritableComparable<HttpBean> {
    //1363157986029 15989002119 E8-99-C4-4E-93-E0:CMCC-EASY 120.196.100.99
    private String id; //编号
    private String tel; //手机号码
    private String mac; //mac地址
    private String ip; //IP地址

    public HttpBean(){
        super();
    }

    public HttpBean(String id, String tel, String mac, String ip){
        this.id = id;
        this.tel = tel;
        this.mac = mac;
        this.ip = ip;
    }

    @Override
    public int compareTo(HttpBean o) {
        return this.id.compareTo(o.getId());
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(id);
        dataOutput.writeUTF(tel);
        dataOutput.writeUTF(mac);
        dataOutput.writeUTF(ip);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        id = dataInput.readLine();
        tel = dataInput.readLine();
        mac = dataInput.readLine();
        ip = dataInput.readLine();
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return id + " " + tel + " " + mac + " " + ip;
    }

}
